//
//  TBRChosseCarMessageC.m
//  TBRentClient
//
//  Created by tonbright on 2018/4/27.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TBRChosseCarMessageC.h"
#import "TBRChooseCarMessageCell.h"
#import "TBRChooseCarHeadView.h"

@interface TBRChosseCarMessageC ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView      *tableView;
@end

@implementation TBRChosseCarMessageC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}

- (void)setupUI {
    //设置导航条
    [self setupNavItem];
    
    //添加tableView
    [self setupTableView];
}

- (void)setupNavItem {
    [self ISG_NavigationBarDefaultBackButtonAndNavigationTitle:@"选择车型"];
}

- (void)setupTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    self.tableView.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.offset(0);
    }];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableFooterView = [UIView new];
    [self.tableView registerNib:[UINib nibWithNibName:@"TBRChooseCarMessageCell" bundle:nil] forCellReuseIdentifier:@"TBRChooseCarMessageCellId"];
    self.tableView.rowHeight = 120;
    self.tableView.tableFooterView = [UIView new];
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, -45, 0, 0)];
    }
    self.tableView.showsVerticalScrollIndicator = NO;
    
}

#pragma mark - 返回组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

#pragma mark - 返回行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 7;
}

#pragma mark - 返回每行内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //自定义cell
    TBRChooseCarMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TBRChooseCarMessageCellId" forIndexPath:indexPath];
    //    cell.goodsModel = self.allGoodsArray[indexPath.row];
    //设置数据
    //返回
    [self setupCell:cell indexPath:indexPath];
    return cell;
}

- (void)setupCell:(TBRChooseCarMessageCell *)cell indexPath:(NSIndexPath *)indexPath {
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    if (self.CarMessageBlock) {
        self.CarMessageBlock(indexPath.row);
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    TBRChooseCarHeadView *chooseCarHeadView = [TBRChooseCarHeadView chooseCarHeadView];
    chooseCarHeadView.frame = CGRectMake(0, 0, Width, 40);
    chooseCarHeadView.chooseCarTypeBlock = ^(NSInteger index) {
        //获取网络数据刷新界面
    };
    return chooseCarHeadView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 40;
}

@end
